package cn.ulc.socket.weapp.service.impl;

import cn.ulc.common.constant.enums.AvailableStatus;
import cn.ulc.socket.weapp.common.BaseService;
import cn.ulc.socket.weapp.model.dto.SiteListDTO;
import cn.ulc.socket.weapp.model.dto.SiteRegionListDTO;
import cn.ulc.socket.weapp.service.SiteServ;
import cn.ulc.store.dao.site.SiteDao;
import cn.ulc.store.dao.site.SiteRegionDao;
import cn.ulc.store.entity.Company;
import cn.ulc.store.entity.site.Site;
import cn.ulc.store.entity.site.SiteRegion;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class SiteServImpl extends BaseService implements SiteServ {

    SiteDao siteDao;
    SiteRegionDao regionDao;
    @Override
    public SiteListDTO findList() {
        Company company = getCurrentCompany();
        List<Site> siteList = siteDao.findListByCompanyId(company.getId(),AvailableStatus.AVAILABLE);
        return new SiteListDTO(siteList);
    }

    @Override
    public SiteRegionListDTO findRegionList(Long siteId) {
        List<SiteRegion> regionList = regionDao.findBySiteId(siteId);
        return new SiteRegionListDTO(regionList);
    }
}
